<div class="full">

    <?php 
        $title = 'Aukcja #ID '.$this->auction->getAuction_id().
                ' - '.$this->auction->getTitle();
        echo $this->partial('partials/_sectionTitle.phtml', 
            array('title'=> $title));
    ?>
    
     
    <div class="first threefifth">
        <table class="datalist">
            <tr>
                <td>Autor</td>
                <td><?php echo $this->auction->getMarketEntity_id(); ?></td>
            </tr>
            <?php if ($this->status != 'prep') { ?>
            <tr>
                <td>Początek aukcji</td>
                <td><?php echo $this->dateToString(
                        $this->auction->getStartTime(),TRUE); 
                    ?>
                </td>
            </tr>
            <tr>
                <td>Koniec aukcji</td>
                <td><?php echo $this->dateToString(
                        $this->auction->getEndTime(),TRUE); 
                    ?>
                </td>
            </tr>
            <?php } ?>
            <tr>
                <td>
                    <?php 
                            if($this->status == 'open'){
                                ?>Pozostało<?
                            } elseif ($this->status == 'prep') {
                                ?>Przygotowanie<?
                            } else {
                                ?>Zakończona<?
                            }
                    ?>
                </td>
                         <td>
                    <?php 
                        echo $this->timeToEnd($this->auction->getEndTime()); 
                    ?>
            </td>
            </tr>
            <tr>
                <td>Status</td>
                <td>
                    <strong>
                        <?php 
                            if($this->status == 'open'){
                                ?><span style="color: green">Otwarta<span><?
                            } elseif ($this->status == 'prep') {
                                ?><span style="color: orange">Przygotowanie<span><?
                            } else {
                                ?><span style="color: red">Zamknięta</span><?
                            }
                        ?>
                    </strong>
                </td>
            </tr>
        </table>
        <br />
    </div>
    
    
    <div class ="twofifth last">
        <? if(!$this->status == 'prep') { ?>
        <a href="
            <?php echo $this->url(array('controller'=>'offers',
                'action'=>'inAuction',
                'id'=>$this->auction->getAuction_id()),
                    null,
                    true); ?>">
            <button class="green styled_button">Składanie ofert</button></a>
        <? } ?>
    </div>
</div>


      

<div class="full">
    
    <? echo $this->partial('partials/_sectionTitle.phtml', 
            array('title'=> 'Opis')); ?>
    <p class='round_5 shadow_out_4 bg_greenyellow dbox2' >
        <?php echo $this->auction->getDescription() ?>
    </p>
    </div>
<div class="full">

 <? echo $this->partial('partials/_sectionTitle.phtml', 
            array('title'=> 'Towary')); ?>
        <table class="datalist" style="width: 50%">
        <? foreach ($this->commodities as $comm) {
            ?>
            <tr>
                <td>
                   <? echo $comm->getName()?>
                </td>
                <td>
                    <? 
                    $share = $comm->getShareFactor($this->user); 
                    if ($share == 1) {?>
                        Kupno
                    <? } elseif($share == -1) {?>
                        Sprzedaż
                    <? } ?>
                </td>
                <td>
                    <a href="/commodities/show/format/html/id/<? echo 
                    $comm->getCommodity_id()?>/auction/<? echo 
                    $this->auction->getAuction_id(); ?>" class="nyroModal">
                        Szczegóły
                    </a>
                </td>
            </tr>
            <?
        } ?>
    </table>
    </div>
 <div class="full">

  <? echo $this->partial('partials/_sectionTitle.phtml', 
            array('title'=> 'Twoje oferty')); ?>
     <div id="offers">
         <?
          foreach ($this->offers as $offer) {
              echo $this->partial('partials/_offerStub.phtml', 
                array('offer'=> $offer)); 
          }
         ?>
     </div>
        <a href="
            <?php echo $this->url(array('controller'=>'offers',
                'action'=>'new',
                'auction'=>$this->auction->getAuction_id()),
                    null,
                    true); ?>">
            <button class="green styled_button">Nowa oferta</button>
        </a>
        <?php echo $this->ajaxLink("wyniki",
                "/auctions/results/auction/".$this->auction->getAuction_id().'/format/json',        
                array(
                    'complete' =>
                    'processResults(data);',
                    'class' => 
                    'styled_button grey',)
                ); 
        ?>
</div>
<? if($this->status != 'open' && $this->status != 'prep' ){ ?>
 <div class="full">

  <? echo $this->partial('partials/_sectionTitle.phtml', 
            array('title'=> 'Zwyciezcy aukcji')); ?>
     <div id="winners">
         <?
          foreach ($this->winners as $winner) {
              echo $this->partial('partials/_winner.phtml', 
                array('winner'=> $winner)); 
          }
         ?>
    </div>
</div>
<? } ?>
